﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace ThunderboltCustomControlLibrary;
/// <summary>尾部带按钮的文本框 </summary>
public class TailButtonTextBox:TextBox
{
	static TailButtonTextBox()
	{
		DefaultStyleKeyProperty.OverrideMetadata(typeof(TailButtonTextBox), new FrameworkPropertyMetadata(typeof(TailButtonTextBox)));
	}
	/// <summary>提示文本 </summary>
	[CategoryAttribute("Custom attribute"), DescriptionAttribute("Gets or sets the default text")]
	public string PlaceHolder
	{
		get { return (string)GetValue(PlaceHolderProperty); }
		set { SetValue(PlaceHolderProperty, value); }
	}
	[CategoryAttribute("Custom attribute"), DescriptionAttribute("Gets or sets the default text")]
	public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty.Register("PlaceHolder", typeof(string), typeof(TailButtonTextBox));


	/// <summary>按钮文本 </summary>
	[CategoryAttribute("Custom attribute"), DescriptionAttribute("Gets or sets the button content")]
	public string ButtonContent
	{
		get { return (string)GetValue(ButtonContentProperty); }
		set { SetValue(ButtonContentProperty, value); }
	}
	[CategoryAttribute("Custom attribute"), DescriptionAttribute("Gets or sets the default text")]
	public static readonly DependencyProperty ButtonContentProperty = DependencyProperty.Register("ButtonContent", typeof(string), typeof(TailButtonTextBox));


	public override void OnApplyTemplate()
	{
		base.OnApplyTemplate();

	}

	protected override void OnTextChanged(TextChangedEventArgs e)
	{
		if (this.Text != PlaceHolder)
		{
			base.OnTextChanged(e);
		}
	}
}